package com.ylb.rent.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ylb.rent.dao.ApartmentForbidMapper;
import com.ylb.rent.entity.ApartmentFeetype;
import com.ylb.rent.entity.ApartmentForbid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ylb.rent.dao.ForbidMapper;
import com.ylb.rent.entity.Forbid;
import com.ylb.rent.service.IForbidService;

/**
 * 禁止事项Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-02
 */
@Service
public class ForbidServiceImpl implements IForbidService 
{
    @Autowired
    private ForbidMapper forbidMapper;

    @Autowired
    private ApartmentForbidMapper apartmentForbidMapper;

    @Override
    public List<Forbid> selectListByApartmentId(Long aId) {
        ApartmentForbid selector = ApartmentForbid.builder().apartmentId(aId).build();


        List<ApartmentForbid> list = apartmentForbidMapper.selectApartmentForbidList(selector);
//        得到stuffId集合
        List<Long> idList = list.stream().map(ApartmentForbid::getForbidId).collect(Collectors.toList());
        return forbidMapper.selectBatchIds(idList);
    }

    /**
     * 查询禁止事项
     * 
     * @param id 禁止事项主键
     * @return 禁止事项
     */
    @Override
    public Forbid selectForbidById(Long id)
    {
        return forbidMapper.selectForbidById(id);
    }

    /**
     * 查询禁止事项列表
     * 
     * @param forbid 禁止事项
     * @return 禁止事项
     */
    @Override
    public List<Forbid> selectForbidList(Forbid forbid)
    {
        return forbidMapper.selectForbidList(forbid);
    }

    /**
     * 新增禁止事项
     * 
     * @param forbid 禁止事项
     * @return 结果
     */
    @Override
    public int insertForbid(Forbid forbid)
    {
        return forbidMapper.insertForbid(forbid);
    }

    /**
     * 修改禁止事项
     * 
     * @param forbid 禁止事项
     * @return 结果
     */
    @Override
    public int updateForbid(Forbid forbid)
    {
        return forbidMapper.updateForbid(forbid);
    }

    /**
     * 批量删除禁止事项
     * 
     * @param ids 需要删除的禁止事项主键
     * @return 结果
     */
    @Override
    public int deleteForbidByIds(Long[] ids)
    {
        return forbidMapper.deleteForbidByIds(ids);
    }

    /**
     * 删除禁止事项信息
     * 
     * @param id 禁止事项主键
     * @return 结果
     */
    @Override
    public int deleteForbidById(Long id)
    {
        return forbidMapper.deleteForbidById(id);
    }
}
